﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/master/CenterMain.Master"
    CodeBehind="Supplement.aspx.cs" Inherits="com.huigo.B2B.Web.center.account.Supplement" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script type="text/javascript">
    function show(amount) {
        var rate = "<%=AlipayRate %>";
        var payAmount = amount.value;
        if (!isNaN(payAmount)) {
            if ($.trim(payAmount) == "") {
                payAmount = "0";
            }
            var check = document.getElementById('amount6').checked;
            if (check == true) {
                $("#tbPayPriceAlipayCredit").removeAttr("disabled");
            }
            else {
                $("#tbPayPriceAlipayCredit").val("");
                $("#tbPayPriceAlipayCredit").attr("disabled", "disabled");
            }
            var alipyAmount = (payAmount / (1 - rate));

            var amountCount = formatFloat(alipyAmount);
            $("#price").html(amountCount);
        }
        else {
            $("#price").html("0");
        }
    }
    function formatFloat(currency) {
        var currency1 = currency.toString().substring(0, (currency.toString().indexOf('.') + 3));
        var currency2 = currency.toString().substring(0, (currency.toString().indexOf('.') + 4));
        if (currency1 - currency2 < 0) {
            currency1 = parseFloat(currency1) + parseFloat(0.01);
        }
        return currency1.toString().substring(0, (currency1.toString().indexOf('.') + 3));
    }
    function checkSubmit() {
        var check = document.getElementById('amount6').checked;
        if (check == true) {
            var amount = $("#tbPayPriceAlipayCredit").val();
            if (!isNaN(amount)) {
                if ($.trim(amount) == "") {
                    alert("请输入金额");
                    return false;
                }
                else if (parseFloat(amount) > 0) {
                    return true;
                }
                else {
                    alert("请输入正确的金额");
                    return false;
                }
            }
            else {
                alert("请输入正确的金额");
                return false;
            }
        } 
    }
</script>
    <style type="text/css">
        .amount-select span
        {
            float: left;
            display: inline-block;
            width: 150px;
            margin-right: 20px;
        }
    </style>
    <form name="formAliPay" action="Supplement.aspx" target="_blank" method="post">
    <h3 class="greybg">
        充值</h3>
    <table class="table table-bordered table-striped responsive-utilities">
        <thead>
            <tr>
                <th>
                    您的可用余额：￥<span id="userFee"><%=GetUserFee() %></span>
                </th>
            </tr>
            <tr>
                <th>
                    <dl>
                        <dt>充值金额：</dt>
                        <dd class="amount-select" style="float: left;">
                            <span>
                                <input id="amount1" name="amount" type="radio" value="100" onclick="show(this)" checked="checked"
                                    style="float: left;" /><label for="amount1" style="float: left;">￥100.00</label></span>
                            <span>
                                <input id="amount2" name="amount" type="radio" value="500" onclick="show(this)" style="float: left;" /><label
                                    for="amount2" style="float: left;">￥500.00</label></span> <span>
                                        <input id="amount3" name="amount" type="radio" value="1000" onclick="show(this)"
                                            style="float: left;" /><label for="amount3" style="float: left;">￥1000.00</label></span>
                            <span>
                                <input id="amount4" name="amount" type="radio" value="2000" onclick="show(this)"
                                    style="float: left;" /><label for="amount4" style="float: left;">￥2000.00</label></span>
                            <span>
                                <input id="amount5" name="amount" type="radio" value="5000" onclick="show(this)"
                                    style="float: left;" /><label for="amount5" style="float: left;">￥5000.00</label></span>
                            <span>
                                <input id="amount6" name="amount" type="radio" value="0" onclick="show(this)" style="float: left;" /><label
                                    for="amount6" style="float: left;">其他金额&nbsp;&nbsp;￥</label><input type="text" size="8"
                                        id="tbPayPriceAlipayCredit" name="tbPayPrice" onblur="show(this)" style="padding: 0px 0px;"
                                        disabled="disabled" /></span>
                        </dd>
                    </dl>
                </th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th>
                    选择充值方式
                </th>
            </tr>
            <tr>
                <th>
                    > 支付宝
                </th>
            </tr>
            <tr>
                <td>
                    <form name="formAliPay" target="_blank" method="post">
                    实际付款金额：￥<span id="price" class="red" style="font-size:18px;margin-right:30px;"><%=GetAlipayTotalPayPrice() %></span>
                    <input name="paytype" value="ALIPAY" type="hidden" /><input type="submit" onclick="return checkSubmit();" id="alipaySubmit"
                        name="button" value="前往支付宝付款"  class="button btn-big btn-orange"/></form>
                </td>
            </tr>
        </tbody>
    </table>
</asp:Content>
